<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="p" uri="http://primefaces.prime.com.tr/ui"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Página Compromisso</title>
            <p:resources />

        </head>
        <body>
                <h:form>
                    <p:panel header="Compromisso(s)">
                <p:dataTable value="#{compromissoManagedBean.compromissos}" var="item"
            paginator="true" rows="5" emptyMessage="Compromissos não encontrados!"  >
                    <h:inputHidden value="#{item.idCompromisso}"/>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Descrição" />
                        </f:facet>
                        <h:outputText value="#{item.descricao}" />
                    </p:column> 
                    
                    <p:column>
                         <f:facet name="header">
                                <h:outputText value="Data Inicial"/>
                          </f:facet>
                            <h:outputText value="#{item.dataInicio}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm"/>
                            </h:outputText>
                     </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Data Final"/>
                            </f:facet>
                            <h:outputText value="#{item.dataFim}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm"/>
                            </h:outputText>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Ações"/>
                            </f:facet>   
                            <h:commandLink value=" Editar" action="#{compromissoManagedBean.inicioEditarCompromisso}">
                                <f:setPropertyActionListener target="#{compromissoManagedBean.compromisso}" value="#{item}"/>
                            </h:commandLink>
                            <h:outputText value=" / "/>
                            <h:commandLink value="Excluir" action="#{compromissoManagedBean.excluirCompromisso}">
                                <f:setPropertyActionListener target="#{compromissoManagedBean.compromisso}" value="#{item}"/>
                            </h:commandLink>
                            
                        </p:column> 
                    </p:dataTable>
                </p:panel>
                </h:form>
                
                 <h:form>
                    <p:commandButton value="Voltar" action="retornar" immediate="true" ajax="false"/>
                    <p:commandButton value="Adicionar" action="" immediate="true" ajax="false"/>
                </h:form>    
 
        </body>
    </html>
</f:view>